using System;
using System.IO;
using System.Xml.Schema;
using System.Text;

namespace GeoFramework
{
	public class Xml
	{
        public const string Namespace = "http://geoframeworks.com";
        public const string RawSchema = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"
+ "<xs:schema id=\"GeoFramework\" targetNamespace=\"http://geoframeworks.com\" elementFormDefault=\"qualified\" xmlns=\"http://geoframeworks.com\" xmlns:mstns=\"http://geoframeworks.com\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\r\n"
  + "<xs:simpleType name=\"DistanceUnit\">\r\n"
    + "<xs:restriction base=\"xs:string\">\r\n"
      + "<xs:enumeration value=\"Meters\" />\r\n"
      + "<xs:enumeration value=\"Centimeters\" />\r\n"
      + "<xs:enumeration value=\"Feet\" />\r\n"
      + "<xs:enumeration value=\"Inches\" />\r\n"
      + "<xs:enumeration value=\"Kilometers\" />\r\n"
      + "<xs:enumeration value=\"NauticalMiles\" />\r\n"
      + "<xs:enumeration value=\"StatuteMiles\" />\r\n"
    + "</xs:restriction>\r\n"
  + "</xs:simpleType>\r\n"
  + "<xs:complexType name=\"Distance\">\r\n"
    + "<xs:simpleContent>\r\n"
      + "<xs:extension base=\"xs:double\">\r\n"
        + "<xs:attribute name=\"Units\" type=\"DistanceUnit\" />\r\n"
      + "</xs:extension>\r\n"
    + "</xs:simpleContent>\r\n"
  + "</xs:complexType>\r\n"
  + "<xs:simpleType name=\"Angle\">\r\n"
    + "<xs:restriction base=\"xs:double\" />\r\n"
  + "</xs:simpleType>\r\n"
  + "<xs:simpleType name=\"Azimuth\">\r\n"
    + "<xs:restriction base=\"xs:double\" />\r\n"
  + "</xs:simpleType>\r\n"
  + "<xs:simpleType name=\"Elevation\">\r\n"
    + "<xs:restriction base=\"xs:double\" />\r\n"
  + "</xs:simpleType>\r\n"
  + "<xs:simpleType name=\"Latitude\">\r\n"
    + "<xs:restriction base=\"xs:double\" />\r\n"
  + "</xs:simpleType>\r\n"
  + "<xs:simpleType name=\"Longitude\">\r\n"
    + "<xs:restriction base=\"xs:double\" />\r\n"
  + "</xs:simpleType>\r\n"
  + "<xs:complexType name=\"Speed\">\r\n"
    + "<xs:simpleContent>\r\n"
      + "<xs:extension base=\"xs:double\">\r\n"
        + "<xs:attribute name=\"Units\" type=\"SpeedUnit\" />\r\n"
      + "</xs:extension>\r\n"
    + "</xs:simpleContent>\r\n"
  + "</xs:complexType>\r\n"
  + "<xs:simpleType name=\"SpeedUnit\">\r\n"
    + "<xs:restriction base=\"xs:string\">\r\n"
      + "<xs:enumeration value=\"Knots\" />\r\n"
      + "<xs:enumeration value=\"MetersPerSecond\" />\r\n"
      + "<xs:enumeration value=\"StatuteMilesPerHour\" />\r\n"
      + "<xs:enumeration value=\"KilometersPerHour\" />\r\n"
      + "<xs:enumeration value=\"KilometersPerSecond\" />\r\n"
      + "<xs:enumeration value=\"FeetPerSecond\" />\r\n"
    + "</xs:restriction>\r\n"
  + "</xs:simpleType>\r\n"
  + "<xs:complexType name=\"Position\">\r\n"
    + "<xs:sequence>\r\n"
      + "<xs:element name=\"Latitude\" type=\"Latitude\" minOccurs=\"1\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Longitude\" type=\"Longitude\" minOccurs=\"1\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"ZoneLetter\" type=\"xs:string\" minOccurs=\"0\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"ZoneNumber\" type=\"xs:int\" minOccurs=\"0\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Easting\" type=\"Distance\" minOccurs=\"0\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Northing\" type=\"Distance\" minOccurs=\"0\" maxOccurs=\"1\" />\r\n"
    + "</xs:sequence>\r\n"
    + "<xs:attribute name=\"Datum\" type=\"xs:string\" />\r\n"
  + "</xs:complexType>\r\n"
  + "<xs:simpleType name=\"AreaUnit\">\r\n"
    + "<xs:restriction base=\"xs:string\">\r\n"
      + "<xs:enumeration value=\"SquareMeters\" />\r\n"
      + "<xs:enumeration value=\"SquareCentimeters\" />\r\n"
      + "<xs:enumeration value=\"SquareFeet\" />\r\n"
      + "<xs:enumeration value=\"SquareInches\" />\r\n"
      + "<xs:enumeration value=\"SquareKilometers\" />\r\n"
      + "<xs:enumeration value=\"SquareNauticalMiles\" />\r\n"
      + "<xs:enumeration value=\"SquareStatuteMiles\" />\r\n"
      + "<xs:enumeration value=\"Acres\" />\r\n"
    + "</xs:restriction>\r\n"
  + "</xs:simpleType>\r\n"
  + "<xs:complexType name=\"Area\">\r\n"
    + "<xs:simpleContent>\r\n"
      + "<xs:extension base=\"xs:double\">\r\n"
        + "<xs:attribute name=\"Units\" type=\"AreaUnit\" />\r\n"
      + "</xs:extension>\r\n"
    + "</xs:simpleContent>\r\n"
  + "</xs:complexType>\r\n"
  + "<xs:complexType name=\"CartesianPoint\">\r\n"
    + "<xs:sequence>\r\n"
      + "<xs:element name=\"X\" type=\"Distance\" minOccurs=\"1\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Y\" type=\"Distance\" minOccurs=\"1\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Z\" type=\"Distance\" minOccurs=\"1\" maxOccurs=\"1\" />\r\n"
    + "</xs:sequence>\r\n"
  + "</xs:complexType>\r\n"
  + "<xs:complexType name=\"Ellipsoid\">\r\n"
    + "<xs:sequence>\r\n"
      + "<xs:element name=\"PolarRadius\" type=\"Distance\" minOccurs=\"1\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"EquatorialRadius\" type=\"Distance\" minOccurs=\"1\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Flattening\" type=\"xs:double\" minOccurs=\"0\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"InverseFlattening\" type=\"xs:double\" minOccurs=\"0\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Eccentricity\" type=\"xs:double\" minOccurs=\"0\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"EccentricitySquared\" type=\"xs:double\" minOccurs=\"0\" maxOccurs=\"1\" />\r\n"
    + "</xs:sequence>\r\n"
    + "<xs:attribute name=\"Name\" type=\"xs:string\" />\r\n"
  + "</xs:complexType>\r\n"
  + "<xs:complexType name=\"Datum\">\r\n"
    + "<xs:sequence>\r\n"
      + "<xs:element name=\"Ellipsoid\" type=\"Ellipsoid\" minOccurs=\"1\" />\r\n"
    + "</xs:sequence>\r\n"
    + "<xs:attribute name=\"Name\" type=\"xs:string\" />\r\n"
  + "</xs:complexType>\r\n"
  + "<xs:complexType name=\"GeographicSize\">\r\n"
    + "<xs:sequence>\r\n"
      + "<xs:element name=\"Width\" type=\"Angle\" maxOccurs=\"1\" minOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Height\" type=\"Angle\" maxOccurs=\"1\" minOccurs=\"1\" />\r\n"
    + "</xs:sequence>\r\n"
  + "</xs:complexType>\r\n"
  + "<xs:complexType name=\"GeographicRectangle\">\r\n"
    + "<xs:sequence>\r\n"
      + "<xs:element name=\"Top\" type=\"Latitude\" maxOccurs=\"1\" minOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Left\" type=\"Longitude\" maxOccurs=\"1\" minOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Bottom\" type=\"Latitude\" maxOccurs=\"1\" minOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Right\" type=\"Longitude\" maxOccurs=\"1\" minOccurs=\"1\" />\r\n"
    + "</xs:sequence>\r\n"
  + "</xs:complexType>\r\n"
  + "<xs:complexType name=\"PointD\">\r\n"
    + "<xs:sequence>\r\n"
      + "<xs:element name=\"X\" type=\"xs:double\" minOccurs=\"1\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Y\" type=\"xs:double\" maxOccurs=\"1\" minOccurs=\"1\" />\r\n"
    + "</xs:sequence>\r\n"
  + "</xs:complexType>\r\n"
  + "<xs:complexType name=\"PolarCoordinate\">\r\n"
    + "<xs:sequence>\r\n"
      + "<xs:element name=\"R\" type=\"xs:float\" minOccurs=\"1\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Theta\" type=\"Angle\" maxOccurs=\"1\" minOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Origin\" type=\"Azimuth\" maxOccurs=\"1\" minOccurs=\"0\" default=\"0\" />\r\n"
      + "<xs:element name=\"Orientation\" type=\"PolarCoordinateOrientation\" maxOccurs=\"1\" minOccurs=\"0\" default=\"Clockwise\" />\r\n"
    + "</xs:sequence>\r\n"
  + "</xs:complexType>\r\n"
  + "<xs:simpleType name=\"PolarCoordinateOrientation\">\r\n"
    + "<xs:restriction base=\"xs:string\">\r\n"
      + "<xs:enumeration value=\"Clockwise\" />\r\n"
      + "<xs:enumeration value=\"CounterClockwise\" />\r\n"
    + "</xs:restriction>\r\n"
  + "</xs:simpleType>\r\n"
  + "<xs:complexType name=\"PositionCollection\">\r\n"
    + "<xs:sequence>\r\n"
      + "<xs:element name=\"Position\" type=\"Position\" minOccurs=\"0\" />\r\n"
    + "</xs:sequence>\r\n"
  + "</xs:complexType>\r\n"
  + "<xs:simpleType name=\"Radian\">\r\n"
    + "<xs:restriction base=\"xs:double\" />\r\n"
  + "</xs:simpleType>\r\n"
  + "<xs:complexType name=\"RectangleD\">\r\n"
    + "<xs:sequence>\r\n"
      + "<xs:element name=\"Top\" type=\"xs:double\" maxOccurs=\"1\" minOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Left\" type=\"xs:double\" maxOccurs=\"1\" minOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Bottom\" type=\"xs:double\" minOccurs=\"1\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Right\" type=\"xs:double\" maxOccurs=\"1\" minOccurs=\"1\" />\r\n"
    + "</xs:sequence>\r\n"
  + "</xs:complexType>\r\n"
  + "<xs:complexType name=\"Segment\">\r\n"
    + "<xs:sequence>\r\n"
      + "<xs:element name=\"Start\" type=\"Position\" minOccurs=\"1\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"End\" type=\"Position\" maxOccurs=\"1\" minOccurs=\"1\" />\r\n"
    + "</xs:sequence>\r\n"
  + "</xs:complexType>\r\n"
  + "<xs:complexType name=\"SizeD\">\r\n"
    + "<xs:sequence>\r\n"
      + "<xs:element name=\"X\" type=\"xs:double\" minOccurs=\"1\" maxOccurs=\"1\" />\r\n"
      + "<xs:element name=\"Y\" type=\"xs:double\" maxOccurs=\"1\" minOccurs=\"1\" />\r\n"
    + "</xs:sequence>\r\n"
  + "</xs:complexType>\r\n"
+ "</xs:schema>\r\n";
#if !PocketPC || Framework20
        // Build the schema for the entire GeoFramework
        public static readonly XmlSchema Schema = XmlSchema.Read(new StringReader(RawSchema), null);
#endif

#if Framework20
        public static readonly XmlSchemaSet SchemaSet;
#endif

#if Framework20 || !PocketPC
        static Xml()
        {
#if Framework20
            // Compile the whole thing
            SchemaSet = new XmlSchemaSet();
            SchemaSet.Add(Schema);
            SchemaSet.Compile();
#elif !PocketPC
			// Compile the schema
			Schema.Compile(null);
#endif
        }
#endif
	}
}